#line 1 "/home/ralsina/Desktop/proyectos/qmail/raspf/svn/validators.ragel"
#include <string.h>


#line 6 "../validators.c"
static const char _domain_spec_actions[] = {
	0, 1, 0
};

static const unsigned char _domain_spec_key_offsets[] = {
	0, 0, 4, 8, 13, 29, 46, 63, 
	81, 98, 118, 127, 133
};

static const char _domain_spec_trans_keys[] = {
	37, 46, 33, 126, 37, 45, 95, 123, 
	0, 37, 46, 33, 126, 37, 46, 33, 
	47, 48, 57, 58, 64, 65, 90, 91, 
	96, 97, 122, 123, 126, 37, 45, 46, 
	33, 47, 48, 57, 58, 64, 65, 90, 
	91, 96, 97, 122, 123, 126, 37, 45, 
	46, 33, 47, 48, 57, 58, 64, 65, 
	90, 91, 96, 97, 122, 123, 126, 0, 
	37, 45, 46, 33, 47, 48, 57, 58, 
	64, 65, 90, 91, 96, 97, 122, 123, 
	126, 0, 37, 46, 33, 47, 48, 57, 
	58, 64, 65, 90, 91, 96, 97, 122, 
	123, 126, 76, 86, 108, 118, 67, 68, 
	72, 73, 79, 80, 82, 84, 99, 100, 
	104, 105, 111, 112, 114, 116, 61, 95, 
	114, 124, 125, 43, 46, 48, 57, 61, 
	95, 124, 125, 43, 46, 0
};

static const char _domain_spec_single_lengths[] = {
	0, 2, 4, 3, 2, 3, 3, 4, 
	3, 4, 5, 4, 0
};

static const char _domain_spec_range_lengths[] = {
	0, 1, 0, 1, 7, 7, 7, 7, 
	7, 8, 2, 1, 0
};

static const char _domain_spec_index_offsets[] = {
	0, 0, 4, 9, 14, 24, 35, 46, 
	58, 69, 82, 90, 96
};

static const char _domain_spec_indicies[] = {
	2, 3, 0, 1, 4, 4, 4, 5, 
	1, 6, 2, 3, 0, 1, 2, 3, 
	0, 7, 0, 8, 0, 8, 0, 1, 
	2, 9, 3, 0, 7, 0, 8, 0, 
	8, 0, 1, 2, 9, 3, 0, 8, 
	0, 8, 0, 8, 0, 1, 6, 2, 
	9, 10, 0, 8, 0, 8, 0, 8, 
	0, 1, 6, 2, 3, 0, 7, 0, 
	8, 0, 8, 0, 1, 11, 11, 11, 
	11, 11, 11, 11, 11, 11, 11, 11, 
	11, 1, 12, 12, 12, 12, 4, 12, 
	11, 1, 12, 12, 12, 4, 12, 1, 
	1, 0
};

static const char _domain_spec_trans_targs_wi[] = {
	1, 0, 2, 4, 3, 9, 12, 5, 
	7, 6, 8, 10, 11
};

static const char _domain_spec_trans_actions_wi[] = {
	0, 0, 0, 0, 0, 0, 1, 0, 
	0, 0, 0, 0, 0
};

static const int domain_spec_start = 1;

static const int domain_spec_first_final = 12;

static const int domain_spec_error = 0;

#line 36 "/home/ralsina/Desktop/proyectos/qmail/raspf/svn/validators.ragel"



int validate_domain_spec ( const char *s)
{
    int cs;
    int res = 0;
    char *p= (char *)s;
    char *pe = (char *)s + strlen(s) +1 ;
    
#line 94 "../validators.c"
	{
	cs = domain_spec_start;
	}
#line 46 "/home/ralsina/Desktop/proyectos/qmail/raspf/svn/validators.ragel"
    
#line 100 "../validators.c"
	{
	int _klen;
	unsigned int _trans;
	const char *_acts;
	unsigned int _nacts;
	const char *_keys;

	if ( p == pe )
		goto _out;
_resume:
	if ( cs == 0 )
		goto _out;
	_keys = _domain_spec_trans_keys + _domain_spec_key_offsets[cs];
	_trans = _domain_spec_index_offsets[cs];

	_klen = _domain_spec_single_lengths[cs];
	if ( _klen > 0 ) {
		const char *_lower = _keys;
		const char *_mid;
		const char *_upper = _keys + _klen - 1;
		while (1) {
			if ( _upper < _lower )
				break;

			_mid = _lower + ((_upper-_lower) >> 1);
			if ( (*p) < *_mid )
				_upper = _mid - 1;
			else if ( (*p) > *_mid )
				_lower = _mid + 1;
			else {
				_trans += (_mid - _keys);
				goto _match;
			}
		}
		_keys += _klen;
		_trans += _klen;
	}

	_klen = _domain_spec_range_lengths[cs];
	if ( _klen > 0 ) {
		const char *_lower = _keys;
		const char *_mid;
		const char *_upper = _keys + (_klen<<1) - 2;
		while (1) {
			if ( _upper < _lower )
				break;

			_mid = _lower + (((_upper-_lower) >> 1) & ~1);
			if ( (*p) < _mid[0] )
				_upper = _mid - 2;
			else if ( (*p) > _mid[1] )
				_lower = _mid + 2;
			else {
				_trans += ((_mid - _keys)>>1);
				goto _match;
			}
		}
		_trans += _klen;
	}

_match:
	_trans = _domain_spec_indicies[_trans];
	cs = _domain_spec_trans_targs_wi[_trans];

	if ( _domain_spec_trans_actions_wi[_trans] == 0 )
		goto _again;

	_acts = _domain_spec_actions + _domain_spec_trans_actions_wi[_trans];
	_nacts = (unsigned int) *_acts++;
	while ( _nacts-- > 0 )
	{
		switch ( *_acts++ )
		{
	case 0:
#line 32 "/home/ralsina/Desktop/proyectos/qmail/raspf/svn/validators.ragel"
	{ res = 1; }
	break;
#line 178 "../validators.c"
		}
	}

_again:
	if ( ++p != pe )
		goto _resume;
	_out: {}
	}
#line 47 "/home/ralsina/Desktop/proyectos/qmail/raspf/svn/validators.ragel"
    
    return res;
}


#line 193 "../validators.c"
static const char _IPv4_actions[] = {
	0, 1, 0
};

static const char _IPv4_key_offsets[] = {
	0, 0, 5, 6, 11, 12, 17, 18, 
	23, 24, 27, 30, 36, 39, 42, 45, 
	51, 54, 57, 60, 66, 69, 72, 75, 
	81, 84
};

static const char _IPv4_trans_keys[] = {
	48, 49, 50, 51, 57, 46, 48, 49, 
	50, 51, 57, 46, 48, 49, 50, 51, 
	57, 46, 48, 49, 50, 51, 57, 0, 
	0, 48, 57, 0, 48, 57, 0, 53, 
	48, 52, 54, 57, 0, 48, 53, 46, 
	48, 57, 46, 48, 57, 46, 53, 48, 
	52, 54, 57, 46, 48, 53, 46, 48, 
	57, 46, 48, 57, 46, 53, 48, 52, 
	54, 57, 46, 48, 53, 46, 48, 57, 
	46, 48, 57, 46, 53, 48, 52, 54, 
	57, 46, 48, 53, 0
};

static const char _IPv4_single_lengths[] = {
	0, 3, 1, 3, 1, 3, 1, 3, 
	1, 1, 1, 2, 1, 1, 1, 2, 
	1, 1, 1, 2, 1, 1, 1, 2, 
	1, 0
};

static const char _IPv4_range_lengths[] = {
	0, 1, 0, 1, 0, 1, 0, 1, 
	0, 1, 1, 2, 1, 1, 1, 2, 
	1, 1, 1, 2, 1, 1, 1, 2, 
	1, 0
};

static const char _IPv4_index_offsets[] = {
	0, 0, 5, 7, 12, 14, 19, 21, 
	26, 28, 31, 34, 39, 42, 45, 48, 
	53, 56, 59, 62, 67, 70, 73, 76, 
	81, 84
};

static const char _IPv4_indicies[] = {
	0, 2, 3, 4, 1, 5, 1, 6, 
	7, 8, 9, 1, 10, 1, 11, 12, 
	13, 14, 1, 15, 1, 16, 17, 18, 
	19, 1, 20, 1, 20, 19, 1, 20, 
	16, 1, 20, 21, 19, 16, 1, 20, 
	16, 1, 15, 14, 1, 15, 11, 1, 
	15, 22, 14, 11, 1, 15, 11, 1, 
	10, 9, 1, 10, 6, 1, 10, 23, 
	9, 6, 1, 10, 6, 1, 5, 4, 
	1, 5, 0, 1, 5, 24, 4, 0, 
	1, 5, 0, 1, 1, 0
};

static const char _IPv4_trans_targs_wi[] = {
	2, 0, 21, 23, 22, 3, 4, 17, 
	19, 18, 5, 6, 13, 15, 14, 7, 
	8, 9, 11, 10, 25, 12, 16, 20, 
	24
};

static const char _IPv4_trans_actions_wi[] = {
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 0, 0, 0, 0, 
	0, 0, 0, 0, 1, 0, 0, 0, 
	0
};

static const int IPv4_start = 1;

static const int IPv4_first_final = 25;

static const int IPv4_error = 0;

#line 64 "/home/ralsina/Desktop/proyectos/qmail/raspf/svn/validators.ragel"


int validate_ipv4 ( const char *s)
{
    int cs;
    int res = 0;
    char *p= (char *)s;
    char *pe = (char *)s + strlen(s) +1 ;
    
#line 284 "../validators.c"
	{
	cs = IPv4_start;
	}
#line 73 "/home/ralsina/Desktop/proyectos/qmail/raspf/svn/validators.ragel"
    
#line 290 "../validators.c"
	{
	int _klen;
	unsigned int _trans;
	const char *_acts;
	unsigned int _nacts;
	const char *_keys;

	if ( p == pe )
		goto _out;
_resume:
	if ( cs == 0 )
		goto _out;
	_keys = _IPv4_trans_keys + _IPv4_key_offsets[cs];
	_trans = _IPv4_index_offsets[cs];

	_klen = _IPv4_single_lengths[cs];
	if ( _klen > 0 ) {
		const char *_lower = _keys;
		const char *_mid;
		const char *_upper = _keys + _klen - 1;
		while (1) {
			if ( _upper < _lower )
				break;

			_mid = _lower + ((_upper-_lower) >> 1);
			if ( (*p) < *_mid )
				_upper = _mid - 1;
			else if ( (*p) > *_mid )
				_lower = _mid + 1;
			else {
				_trans += (_mid - _keys);
				goto _match;
			}
		}
		_keys += _klen;
		_trans += _klen;
	}

	_klen = _IPv4_range_lengths[cs];
	if ( _klen > 0 ) {
		const char *_lower = _keys;
		const char *_mid;
		const char *_upper = _keys + (_klen<<1) - 2;
		while (1) {
			if ( _upper < _lower )
				break;

			_mid = _lower + (((_upper-_lower) >> 1) & ~1);
			if ( (*p) < _mid[0] )
				_upper = _mid - 2;
			else if ( (*p) > _mid[1] )
				_lower = _mid + 2;
			else {
				_trans += ((_mid - _keys)>>1);
				goto _match;
			}
		}
		_trans += _klen;
	}

_match:
	_trans = _IPv4_indicies[_trans];
	cs = _IPv4_trans_targs_wi[_trans];

	if ( _IPv4_trans_actions_wi[_trans] == 0 )
		goto _again;

	_acts = _IPv4_actions + _IPv4_trans_actions_wi[_trans];
	_nacts = (unsigned int) *_acts++;
	while ( _nacts-- > 0 )
	{
		switch ( *_acts++ )
		{
	case 0:
#line 60 "/home/ralsina/Desktop/proyectos/qmail/raspf/svn/validators.ragel"
	{res = 1; }
	break;
#line 368 "../validators.c"
		}
	}

_again:
	if ( ++p != pe )
		goto _resume;
	_out: {}
	}
#line 74 "/home/ralsina/Desktop/proyectos/qmail/raspf/svn/validators.ragel"
    
    return res;
}


